﻿using System;
using log4net;

namespace Chowpoo.Util
{
    /// <summary>
    /// 单例助手
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public static class Singleton<T> where T : new()
    {
        private static readonly T instance;
        private static readonly ILog Log = LogManager.GetLogger(typeof(Singleton<T>));

        static Singleton()
        {
            try
            {
                instance = new T();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }

        public static T Instance
        {
            get { return instance; }
        }
    }
}